using System;
using System.IO;

namespace bOS.IO
{
	/// <summary>
	/// Summary description for FileSystem.
	/// </summary>
	public class FileSystem
	{
		public FileSystem()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public static string GetFileContent(string sFileName, bool bTrim)
		{
			if (sFileName.Length > 0 && File.Exists(sFileName))
			{
				StreamReader reader = null;
				string fileContents = string.Empty;

				try
				{
					reader = new StreamReader(sFileName);
					if ( bTrim ) 
					{
						fileContents = reader.ReadToEnd().Trim();
					}
					else
					{
						fileContents = reader.ReadToEnd();
					}
				}
				catch (System.Exception)
				{
					throw;
				}
				finally
				{
					if (reader != null)
					{
						reader.Close();
					}
				}

				if (fileContents.Length == 0)
				{
					throw new System.Exception ("file is empty");
				}

				return fileContents;
			}
			else
			{
				throw new System.Exception ("file does not exist");
			}
		}
	}
}
